const path = require('path')
const webpack = require('webpack')
const clearWebpackPlugin = require('clear-webpack-plugin')
module.exports = {
    mode:'development',
    entry:path.resolve(__dirname,'../src/main.js'),
    output:{
        path:path.resolve(__dirname,'../dist'),
        filename:'js/[name].[hash:8].js',
        chunkFilename:'js/[name]:[hash:8].js',
        publicPath:"./"
    },
    resolve:{
        alias:{
            "@":path.join(__dirname,'../src')
        }
    },
    devServe:{
        port:"8080",
        open:true,
        host:"localhost",
        hot:true,
        proxy:{

        }
    },
    module:{
        rules:[
            {
                test:/\.js$/,
                exclude:/node_module/,
                use:[
                    {loader:'babel-loader'}
                ]
            }
        ]
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),
        new clearWebpackPlugin()
    ]
}

/**
 * 定义入口、出口、模式
 * 热更新、清除上一次构建打包文件
 * es6/7/8转为es5
 * @符号引入文件路径的使用
*/